package com.example.barcodeapp.ui.own.fragment;

import android.webkit.WebChromeClient;
import android.webkit.WebView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.barcodeapp.R;
import com.example.barcodeapp.adapter.KeChengXiangQingAdapter;
import com.example.barcodeapp.base.BaseFragment;
import com.example.barcodeapp.common.Constants;
import com.example.barcodeapp.interfaces.own.IOwn;
import com.example.barcodeapp.persenter.OnePresenterKeChengXiangQing;
import com.example.barcodeapp.ui.own.adapter.KeChengXiangQingTuiJianAdapter;
import com.example.barcodeapp.ui.wode.bean.kechengxiangqingBean;

import butterknife.BindView;


public class KeChengJieShaoFragment extends BaseFragment<IOwn.Persenterkechengxiangqing> implements IOwn.Viewkechengxiangqing {


    @BindView(R.id.web)
    WebView web;
    @BindView(R.id.rvxianqing)
    RecyclerView rvxianqing;

    @Override
    protected int getLayout() {
        return R.layout.fragment_ke_cheng_jie_shao;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected OnePresenterKeChengXiangQing initPersenter() {
        return new OnePresenterKeChengXiangQing();
    }

    @Override
    protected void initData() {
        persenter.getkechengxiangqing(Constants.kechengxiangqing, 2);
    }

    @Override
    public void getkechengxiangqing(kechengxiangqingBean xiLieKeBean) {
        web.loadUrl(xiLieKeBean.getData().getText());
        web.setWebChromeClient(new WebChromeClient());
        web.getSettings().setJavaScriptEnabled(true);
        KeChengXiangQingTuiJianAdapter keChengXiangQingTuiJianAdapter = new KeChengXiangQingTuiJianAdapter(context, xiLieKeBean.getData().getTuijian());
        LinearLayoutManager manager = new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        rvxianqing.setLayoutManager(manager);
        rvxianqing.setAdapter(keChengXiangQingTuiJianAdapter);
        keChengXiangQingTuiJianAdapter.notifyDataSetChanged();
    }
}